home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-E.ZIP / EGAGRAFA.ASM < prev    next >
Assembly Source File  |  1987-12-29  |  3KB  |  173 lines

  1. ;
  2. ; grafix --- egagrafa.asm
  3. ;
  4. ; stuff to plot points fast in 8086 assembler (BLEECH!!!)
  5. ;
  6. ; Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
  7. ;
  8. ; Modified 5/29/87 by sss to allow for different memory models
  9. ;
  10.  
  11.     title    egagrafa
  12.  
  13. include macros.ah
  14.  
  15. sseg
  16. endss
  17.  
  18. g_linsiz  equ    80
  19. g_pixbyte equ    8
  20. ega_gr_data equ 03cfh
  21.  
  22. dseg
  23.  
  24.     ex g_drawbuf,     dword
  25.     ex g_xor,         word
  26.     ex g_xcliplo,     word
  27.     ex g_xcliphi,     word
  28.     ex g_ycliplo,     word
  29.     ex g_ycliphi,     word
  30.  
  31. endds
  32.  
  33.     exProc EGA_point_set
  34.     exProc EGA_point_res
  35.  
  36. cseg    _egagrafa
  37.  
  38. EGA_plot label byte            ; to get accurate profiling data
  39.  
  40. ; plot a point. ax = y; bl = c; cx = x;
  41.  
  42. pBegin    plot
  43.  
  44.     les    si, g_drawbuf        ; get address of buffer
  45.     mov    dx, g_linsiz        ; y * g_linsiz
  46.     mul    dx
  47.     add    si, ax            ; add to offset
  48.     mov    ax, cx            ; x to AC (ohhh... what symmetry!)
  49.     mov    cx, g_pixbyte        ; move it to use it...
  50.     div    cx
  51.     add    si, ax            ; add quotient to offset (now complete)
  52.     mov    al, 80h            ; make mask
  53.     mov    cx, dx
  54.     shr    ax, cl            ; shift it
  55.     mov    dx, ega_gr_data        ; shove it out to the mask register
  56.     out    dx, al
  57.     mov    al, es:[si]        ; read data into latches
  58.     mov    es:[si], al        ; and do a write
  59.     ret
  60.  
  61. pEnd    plot
  62.  
  63. ;
  64. ; C interface for point plotter
  65. ;
  66. ; EGA_point(x, y, c)
  67. ;
  68.  
  69. pBegin    EGA_point
  70.  
  71.     push    bp
  72.     mov    bp, sp
  73.     push    si
  74.     push    di
  75.  
  76.     push    [bp+argbase+4]            ; call setup routine
  77.     call    EGA_point_set
  78.     add    sp, 2
  79.  
  80.     mov    ax, [bp+argbase+2]
  81.     mov    bx, [bp+argbase+4]
  82.     mov    cx, [bp+argbase]
  83.     call    plot
  84.  
  85.     call    EGA_point_res        ; reset EGA
  86.  
  87.     pop    di
  88.     pop    si
  89.     mov    sp, bp
  90.     pop    bp
  91.     ret
  92.  
  93. pEnd    EGA_point
  94.  
  95. ;
  96. ; write for pixels for circle drawing
  97. ;
  98. ; void EGA_write_pix(x1, y1, x2, y2, c)
  99. ;
  100. ; can just ignore color here 'cause that's all setup at setup time...
  101. ;
  102.  
  103. pBegin    EGA_write_pix
  104.  
  105.     push    bp
  106.     mov    bp, sp
  107.     push    si
  108.     push    di
  109.  
  110.     mov    cx, [bp+argbase]    ; cx = x1
  111.     cmp    cx, g_xcliplo        ; check for clipping
  112.     jb    w2
  113.     cmp    cx, g_xcliphi
  114.     ja    w2
  115.  
  116.     mov    ax, [bp+argbase+2]    ; ax = y1
  117.     cmp    ax, g_ycliplo        ; do clipping
  118.     jb    w1
  119.     cmp    ax, g_ycliphi
  120.     ja    w1
  121.  
  122.     push    cx            ; plot (x1, y1)
  123.     call    plot
  124.     pop    cx
  125.  
  126. w1:    mov    ax, [bp+argbase+6]    ; ax = y2
  127.     cmp    ax, g_ycliplo
  128.     jb    w2
  129.     cmp    ax, g_ycliphi
  130.     ja    w2
  131.  
  132.     call    plot            ; plot (x1, y2)
  133.  
  134. w2:    mov    cx, [bp+argbase+4]    ; cx = x2
  135.     cmp    cx, g_xcliplo
  136.     jb    w4
  137.     cmp    cx, g_xcliphi
  138.     ja    w4
  139.  
  140.     mov    ax, [bp+argbase+2]    ; ax = y1
  141.     cmp    ax, g_ycliplo        ; do clipping
  142.     jb    w3
  143.     cmp    ax, g_ycliphi
  144.     ja    w3
  145.  
  146.     push    cx            ; plot (x2, y1)
  147.     call    plot
  148.     pop    cx
  149.  
  150. w3:    mov    ax, [bp+argbase+6]    ; ax = y2
  151.     cmp    ax, g_ycliplo
  152.     jb    w4
  153.     cmp    ax, g_ycliphi
  154.     ja    w4
  155.  
  156.     call    plot            ; plot (x2, y2)
  157.  
  158. w4:    pop    di
  159.     pop    si
  160.     mov    sp, bp
  161.     pop    bp
  162.     ret
  163.  
  164. pEnd    EGA_write_pix
  165.  
  166.     df_ EGA_point
  167.     df_ EGA_write_pix
  168.     df_ EGA_plot
  169.  
  170. endcs    _egagrafa
  171.  
  172. end
  173.